﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DesignLayOut_QLQTPM_Team7.DAO;

namespace QLQTPM_ThuDuc_Group7.DAO
{
    class TinhThanhDAO
    {
        public static DataTable LoadTinhThanh()
        {
            string sql = "select * from TINHTHANH";
            DataProvider dtb = new DataProvider();
            return dtb.executeQuery(sql);
        }

        public static int TimTinhThanh(string info)
        {
            string sql = "select * from TINHTHANH where TenTinhThanh='" + info + "'";
            DataProvider dtb = new DataProvider();
            return (int)dtb.executeQuery(sql).Rows[0]["MaTinhThanh"];
        }

        public static bool TonTai(string info)
        {
            DataProvider dtb = new DataProvider();
            string sql = "";
            sql = "Select * from TINHTHANH where TenTinhThanh ='" + info + "'";
            if (dtb.executeQuery(sql).Rows.Count != 0)
            {
                return true;
            }
            return false;
        }

        public static bool ThemMoiTinhThanh(string info)
        {
            DataProvider dtb = new DataProvider();
            string sql = "";
            sql = "Insert into TINHTHANH(TenTinhThanh) values('" + info + "')";
            return dtb.executeNonQuery(sql);
        }
    }
}
